package com.ruoyi.system.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EvChargingMapper;
import com.ruoyi.system.domain.EvCharging;
import com.ruoyi.system.domain.vo.EvChargingStatsVo;
import com.ruoyi.system.service.IEvChargingService;

/**
 * 电动车充电记录Service业务层处理
 * 
 * @author camelminger
 * @date 2025-11-01
 */
@Service
public class EvChargingServiceImpl implements IEvChargingService 
{
    @Autowired
    private EvChargingMapper evChargingMapper;

    /**
     * 查询电动车充电记录
     * 
     * @param chargeId 电动车充电记录主键
     * @return 电动车充电记录
     */
    @Override
    public EvCharging selectEvChargingByChargeId(Long chargeId)
    {
        return evChargingMapper.selectEvChargingByChargeId(chargeId);
    }

    /**
     * 查询电动车充电记录列表
     * 
     * @param evCharging 电动车充电记录
     * @return 电动车充电记录
     */
    @Override
    public List<EvCharging> selectEvChargingList(EvCharging evCharging)
    {
        return evChargingMapper.selectEvChargingList(evCharging);
    }

    /**
     * 新增电动车充电记录
     * 
     * @param evCharging 电动车充电记录
     * @return 结果
     */
    @Override
    public int insertEvCharging(EvCharging evCharging)
    {
        evCharging.setCreateTime(DateUtils.getNowDate());
        return evChargingMapper.insertEvCharging(evCharging);
    }

    /**
     * 修改电动车充电记录
     * 
     * @param evCharging 电动车充电记录
     * @return 结果
     */
    @Override
    public int updateEvCharging(EvCharging evCharging)
    {
        return evChargingMapper.updateEvCharging(evCharging);
    }

    /**
     * 批量删除电动车充电记录
     * 
     * @param chargeIds 需要删除的电动车充电记录主键
     * @return 结果
     */
    @Override
    public int deleteEvChargingByChargeIds(Long[] chargeIds)
    {
        return evChargingMapper.deleteEvChargingByChargeIds(chargeIds);
    }

    /**
     * 删除电动车充电记录信息
     * 
     * @param chargeId 电动车充电记录主键
     * @return 结果
     */
    @Override
    public int deleteEvChargingByChargeId(Long chargeId)
    {
        return evChargingMapper.deleteEvChargingByChargeId(chargeId);
    }

    /**
     * 统计充电记录数值
     *
     * @param beginTime 开始时间
     * @param endTime 结束时间
     * @param granularity 粒度
     * @return 统计数据
     */
    @Override
    public List<EvChargingStatsVo> selectChargingStatistics(Date beginTime, Date endTime, String granularity)
    {
        return evChargingMapper.selectChargingStatistics(beginTime, endTime, granularity);
    }
}
